<ul>
<?php
/* EXPERIMENTAL-GETS CATEGORIES FROM DB, DISPLAYS HEIRARCHY
foreach($db->categories->category as $category) {
  if($category['parent'] == "none") {
    echo getCategory($category);
  }
}
function getCategory($cat) {
  $catname = $cat['name'];
  echo "<li><a href='?category=$catname'>$catname</a></li>\n<ul>\n";
  foreach($db->categories->category as $subcat) {
    if($subcat['parent'] == $catname) {
      getCategory($subcat);
    }
  }
  echo "</ul>\n";
}
*/
// works for the time being...
$categorylist = array();
// get all the categories
foreach($db->pages[0]->page as $page) {
  $pagecategories = split(" ",$page['categories']);
  foreach($pagecategories as $category) {
	  $categorylist[$category] += 1;
  }
}
// print 'em out
for($i=0; $i<count($categorylist); $i++) {
	$category = each($categorylist);
	$categoryname = $category['key'];
	echo "<li><a href='?category=$categoryname'>$categoryname</a></li>\n";
} 
?>
</ul>